#include<iostream>
#include<thread>
#include<mutex>
using namespace std;

//void Print(int n, int* x, mutex* lock)
//{
//	lock->lock();
//	for (int i = 0; i < n; i++) {
//		(*x)++;
//	}
//	lock->unlock();
//}
//
//int main()
//{
//	int x = 0;
//	mutex lock;
//	thread t1(Print, 10000, &x, &lock);
//	thread t2(Print, 20000, &x, &lock);
//
//	t1.join();
//	t2.join();
//
//	cout << x << endl;
//	return 0;
//}

int main()
{
	int x = 0;
	mutex lock;
	auto Print = [&x, &lock](int n)
		{
			lock.lock();
			for (int i = 0; i < n; i++) {
				x++;
			}
			lock.unlock();
		};

	thread t1(Print, 100000);
	thread t2(Print, 200000);
	t1.join();
	t2.join();

	cout << x << endl;
	return 0;
}